#!/usr/bin/env node

import { QDRANT_COLLECTION_NAME, JINA_EMBEDDING_DIMENSIONS } from './conf.js'
import QDRANT from './QDRANT.js'

// 初始化集合（如果不存在）
await (async () => {
  try {
    await QDRANT.getCollection(QDRANT_COLLECTION_NAME);
    return
  } catch (error) {
    if (error.status !== 404) {
      throw error;
    }
  }

  await QDRANT.createCollection(QDRANT_COLLECTION_NAME, {
    vectors: {
      size: JINA_EMBEDDING_DIMENSIONS,
      distance: "Dot", // Jina 推荐使用 Dot product
    },
  });
  console.log(`集合 ${QDRANT_COLLECTION_NAME} 创建成功`);
})()

